package org.come.mouslisten;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import org.come.Frame.TestpackJframe;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.PawnJfpanel;
import org.come.entity.Goodstable;
import org.come.until.GoodsListFromServerUntil;
import org.come.until.MessagrFlagUntil;

/**
 * 类说明
 * 
 * @author 黄建彬
 * @date 2017年12月21日 新建
 * 
 * 
 *       典当的时候,选择典当的物品进行监听
 */

public class PawnChoseMouslisten implements MouseListener {

    private int goodsPlace;// 格子的位置
    private PawnJfpanel jfpanel;

    public PawnChoseMouslisten(int goodsPlace, PawnJfpanel jfpanel) {
        super();
        this.goodsPlace = goodsPlace;
        this.jfpanel = jfpanel;
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        // TODO Auto-generated method stub

    }

    @Override
    public void mousePressed(MouseEvent e) {
        jfpanel.xuanzhong(
                GoodsListFromServerUntil.getGoodslist()[goodsPlace + GoodsListFromServerUntil.Pagenumber * 24],
                goodsPlace,e.getButton() == MouseEvent.BUTTON3);
    }

    @Override
    public void mouseReleased(MouseEvent e) {

    }

    @Override
    public void mouseEntered(MouseEvent e) {
        if (MessagrFlagUntil.ImgFlagImg.equals(MessagrFlagUntil.MOUSE1)) {
            MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE12);
        }

        Goodstable goodstable = GoodsListFromServerUntil.getGoodslist()[goodsPlace
                + GoodsListFromServerUntil.Pagenumber * 24];
        if (goodstable != null) {
            jfpanel.PaintingText(goodsPlace);
            TestpackJframe.getTestpackJframe().getJpac().PaintingText(goodsPlace);
            ZhuFrame.getZhuJpanel().creatgoodtext(goodstable);
        }
    }

    @Override
    public void mouseExited(MouseEvent e) {
        if (MessagrFlagUntil.ImgFlagImg.equals(MessagrFlagUntil.MOUSE12)) {
            MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE1);
        }
        jfpanel.ClearText(goodsPlace);
        ZhuFrame.getZhuJpanel().cleargoodtext();
    }

}
